<?php

$_this =& $this;

/* @var $_this View */
/* @var $form FormHelper */
/* @var $editForm EditFormHelper */
/* @var $html HtmlHelper */
/* @var $ehtml EHtmlHelper */
/* @var $javascript JavascriptHelper */
/* @var $jqax JqaxHelper */
/* @var $filterBlock FilterBlock */

?><?=$filterBlock->create('Filter', array('url'=>("/{$url_part}/")));?><?php
	$filterBlock->add(
        $form->label('searche', __d(null, 'searche_filter', true).': ', array('class'=>'filter')).
		$form->text('searche', false, array('size' => '17', 'label' => false))
	);
    if (Auth::o()->is('admin') || Auth::o()->is('ARCHIVE')) {
        $filterBlock->add(
            $form->label('archive', __d($po_domain, 'archive', true).': ', array('class'=>'filter')).
            $form->select('archived', array('Y' => __d($po_domain, 'type_INARCHIVE', true), 'N' => __d($po_domain, 'type_NOTINARCHIVE', true)), null, array('label' => false), '')
        );
    }
?><?=$filterBlock->end();?><?php

?><br /><?php

if (count($list->rows)) {

?><?=$this->renderElement('pagination', array('paging' => $list->pagination));?><?php

?><table class="table" cellpadding="0"><?php
?><thead><?php
    ?><tr><?php
        if (Auth::o()->is('REPORTS') || Auth::o()->is('admin')) {
            ?><th class="nw"><?php
            ?></th><?php
        }
        ?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'surname', 'domain' => $po_domain));?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'name', 'domain' => $po_domain));?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'group', 'domain' => $po_domain));?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'email', 'domain' => $po_domain));?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'created', 'msg' => 'created_date', 'domain' => $po_domain));?><?php
        ?></th><?php
        ?><th class="actions nw"></th><?php
    ?></tr><?php
?></thead><?php
?><tbody><?php

    $i = 0;
    foreach ($list->rows as $item) {
        $class = '';
    	if ($i++ % 2 != 0) {
    		$sep = strlen($class) ? ' ' : '';
    		$class .= $sep.'altrow';
    	}
    	$class = strlen($class) ? ' class="'.$class.'"' : '';

        ?><tr <?=$class;?>><?php
            if (Auth::o()->is('REPORTS') || Auth::o()->is('admin')) {
        		?><td class="nw actions"><?php
                    ?><table class="sys_clear" cellpadding="0"><?php
                    ?><tr class="sys_clear"><?php
                        $inactive = empty($item[$modelName]['__allows']['view_reports']);
                        $inactive_str = $inactive ? __d($po_domain, 'reportings_is_absent', true) : false;
                        ?><?=$ehtml->iconLink("reports", __d($po_domain, 'View reports', true), "/candidates/{$item[$modelName]['id']}/reports", array('inactive' => $inactive_str, ));?><?php
                    ?></tr><?php
                    ?></table><?php
                ?></td><?php
            }
    		?><td class="nw"><?php
                ?><?=$item[$modelName]['surname'];?><?php
                ?> / <?php
                ?><?=$item[$modelName]['surname_latin'];?><?php
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=$item[$modelName]['name'];?><?php
                ?> / <?php
                ?><?=$item[$modelName]['name_latin'];?><?php
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=$item['Group']['name'];?><?php
            ?></td><?php
    		?><td class="nw"><?php
                if (!empty($item[$modelName]['email'])) {
                    ?><?=$item[$modelName]['email'];?><?php
                } else {
                    ?>—<?php
                }
            ?></td><?php
    		?><td class="nw"><?php
                ?><?=Date::Short(DATE::SQL2UNIX($item[$modelName]['created']));?><?php
            ?></td><?php
            ?><td class="actions"><?php
                ?><table class="sys_clear" cellpadding="0"><?php
                ?><tr class="sys_clear"><?php
                    $inactive = empty($item[$modelName]['__allows']['admining']);
                    $inactive_str = $inactive;
                ?><?=$ehtml->iconLink("admining", __d('menu', 'Admining', true), "/candidates/{$item[$modelName]['id']}/tools", array('inactive' => $inactive_str));?><?php
                ?></tr><?php
                ?></table><?php
            ?></td><?php
    	?></tr><?php
    }

?></tbody><?php
?></table><?php

?><?=$this->renderElement('pagination', array('paging' => $list->pagination));?><?php

} else {
    ?><span class="additional_msg"><?php
        ?><?=__d($po_domain, 'List is empty', true);?><?php
    ?></span><?php
}

?>